package com.demo.service.base.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.demo.mapper.base.TableRelationMapper;
import com.demo.model.base.TableRelation;
import com.demo.model.base.TableRelationExample;
import com.demo.service.base.TableRelationService;

@Service
public class TableRelationServiceImpl implements TableRelationService {
	@Autowired
	TableRelationMapper mapper;

	@Override
	@Transactional
	public int add(TableRelation record) {
		if (null == record) {
			return 0;
		}
		return mapper.insert(record);
	}

	@Override
	@Transactional
	public int addBatch(List<TableRelation> records) {
		if (null == records || records.size() == 0) {
			return 0;
		}
		return mapper.insertBatch(records);
	}

	@Override
	@Transactional
	public int deleteByCondition(TableRelationExample example) {
		return mapper.deleteByExample(example);
	}

	@Override
	public TableRelation getById(Integer id) {
		return mapper.selectByPrimaryKey(id);
	}

	@Override
	public List<TableRelation> findByCondition(TableRelationExample example) {
		return mapper.selectByExample(example);
	}

	@Override
	public int getCount(TableRelationExample example) {
		return mapper.countByExample(example);
	}

}
